package org.fyv233.missingno_craft.datagen;

import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider;
import net.minecraft.data.client.BlockStateModelGenerator;
import net.minecraft.data.client.ItemModelGenerator;
import net.minecraft.data.client.Models;
import net.minecraft.data.family.BlockFamily;
import net.minecraft.item.ArmorItem;
import org.fyv233.missingno_craft.block.ModBlockFamiles;
import org.fyv233.missingno_craft.block.ModBlocks;
import org.fyv233.missingno_craft.item.ModItems;

public class ModModelsProvider extends FabricModelProvider {
    public ModModelsProvider(FabricDataOutput output) {
        super(output);
    }

    @Override
    public void generateBlockStateModels(BlockStateModelGenerator blockStateModelGenerator) {
        ModBlockFamiles.getFamilies()
                        .filter(BlockFamily::shouldGenerateModels).forEach(
                                        blockFamily -> blockStateModelGenerator.registerCubeAllModelTexturePool(blockFamily.getBaseBlock())
                                            .family(blockFamily));
        blockStateModelGenerator.registerSimpleCubeAll(ModBlocks.MISSINGNO_ORE);
    }

    @Override
    public void generateItemModels(ItemModelGenerator itemModelGenerator) {
        itemModelGenerator.register(ModItems.MISSINGNO_AXE, Models.HANDHELD);
        itemModelGenerator.register(ModItems.MISSINGNO_HOE, Models.HANDHELD);
        itemModelGenerator.register(ModItems.MISSINGNO_PICKAXE, Models.HANDHELD);
        itemModelGenerator.register(ModItems.MISSINGNO_SWORD, Models.HANDHELD);

        itemModelGenerator.register(ModItems.MISSINGNO_INGOT, Models.GENERATED);
        itemModelGenerator.register(ModItems.MISSINGNO_NUGGET, Models.GENERATED);
        itemModelGenerator.register(ModItems.MISSINGNO_PROSPECTER, Models.GENERATED);

        itemModelGenerator.registerArmor((ArmorItem) ModItems.MISSINGNO_HELMET);
        itemModelGenerator.registerArmor((ArmorItem) ModItems.MISSINGNO_CHESTPLATE);
        itemModelGenerator.registerArmor((ArmorItem) ModItems.MISSINGNO_LEGGINGS);
        itemModelGenerator.registerArmor((ArmorItem) ModItems.MISSINGNO_BOOTS);
    }
}
